<template>
    <div>
       
           <div class="layout-main">  
            <el-form ref="sysSms" label-position="right" :label-width="120" :model="sysSms" :rules="rules">
                <input type="hidden" :model="sysSms.id" />
                <el-form-item label="启用关闭" prop="isOpen">
                    <RadioGroup v-model="sysSms.isOpen">
                        <Radio :label="1">
                            <span>开启</span>
                        </Radio>
                        <Radio :label="0">
                            <span>关闭</span>
                        </Radio>
                    </RadioGroup>
                </el-form-item>
                <el-form-item label="短信通道" prop="isReceive">
                    <RadioGroup v-model="sysSms.isReceive">
                        <Radio :label="1">
                            <span>阿里云</span>
                        </Radio>
                        <Radio :label="0">
                            <span>短信宝</span>
                        </Radio>
                    </RadioGroup>
                </el-form-item>
                <el-form-item label="默认签名" prop="signName">
                    <el-input size="small" v-model="sysSms.signName" placeholder="默认签名" style="width: 240px" />
                </el-form-item>
                
                 <el-form-item label="管理员接收手机" prop="adminMobile">
                    <el-input size="small" v-model="sysSms.adminMobile" placeholder="管理员接收手机" style="width: 240px" />
                </el-form-item>
                <template v-if="sysSms.isReceive==1">
                    <el-form-item label="App Key" prop="appKey">
                        <el-input size="small" v-model="sysSms.appKey" placeholder="App Key" style="width: 240px" />
                    </el-form-item>
                    <el-form-item label="App Secret" prop="appSecret">
                        <el-input size="small" v-model="sysSms.appSecret" placeholder="App Secret" style="width: 240px" />
                    </el-form-item>
                </template>
               
                <template v-else>
                    
                    <el-form-item label="短信宝账号" prop="smsbaoUser">
                        <el-input size="small" v-model="sysSms.smsbaoUser" placeholder="短信宝账号" style="width: 240px" />
                    </el-form-item>
                    <el-form-item label="短信宝密码" prop="smsbaoPass">
                        <el-input size="small" v-model="sysSms.smsbaoPass" placeholder="短信宝密码" style="width: 240px" />
                    </el-form-item>
                </template>
            </el-form>
            <div>
                <el-button @click="cancel">取消</el-button>
                <el-button type="primary" :loading="modalLoading" @click="ok">确定</el-button>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    name: 'SysSms',
    data() {
        return {
            loading: false,
            modalLoading: false,

            others: {

            },
            sysSms: {
                isReceive:0,
                isOpen:0
            },
            rules: {},
            sysSmsId: null
        };
    },
    mounted: function() {
        this.sysSmsId = this.$route.params.sysSmsId;
        this.getDetail();

    },
    methods: {
        cbtime: function(value) {
            this.others;
        },
        getDetail: function() {

            var me = this;
            me.showLoading();
            me.$http.post("/sys/syssms/get.action").then(response => {
                var body = response;
                if (body.status == 0) {
                    me.sysSms = body.obj;

                }
                me.hideLoading();
            }, response => {
                me.hideLoading();
            });
        },

        ok: function() {
            var ok = false;
            this.$refs['sysSms'].validate((valid) => {
                ok = valid;
                if (valid) {

                } else {
                    this.errorMessage('请认真填写数据');
                }
            })
            if (!ok) return;
            var me = this;

            me.modalLoading = true;
            me.$http.post("/sys/syssms/doSave.action", me.sysSms).then(response => {
                var body = response;
                if (body.status == 0) {
                    me.successMessage("保存成功！");

                    me.modalEdit = false;

                } else {
                    me.errorMessage( body.info);
                }
                me.modalLoading = false;
            }, response => {
                me.modalLoading = false;
            });
        },
        cancel: function() {
            this.getDetail();
        }
    }
}
</script>
<style scoped>
</style>